/*
 这里写需要完成的内容:
 1,关于NSTimer
 2,关于把UIButton的addTarget改成block事件
 3,对UITextView增加placeholder
 
 
 */

#ifndef DSMacros_h
#define DSMacros_h

static inline BOOL IsEmpty(id thing) {
    return thing == nil ||
    ([thing isEqual:[NSNull null]]) ||
    ([thing respondsToSelector:@selector(length)] && [(NSData *)thing length] == 0) ||
    ([thing respondsToSelector:@selector(count)]  && [(NSArray *)thing count] == 0);
}

static inline BOOL isIPad(void) {
    
    return [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad;
    
}


//系统版本
#define SystemVersion [[[UIDevice currentDevice] systemVersion] floatValue]

#define version(A,B) (return (SystemVersion>(A)&&SystemVersion<(B)))

#define version_later(A) SystemVersion>(A)

#define version_before(B) SystemVersion<(B)


//屏幕宽高

#define sScreenWith [UIScreen mainScreen].bounds.size.width
#define sScreenHeight [UIScreen mainScreen].bounds.size.height

#define WidthAuto(x) (sScreenWith/375 * x)
#define HeightAuto(y) (sScreenHeight/667 * y)

//RGB颜色
//#define RGB(r, g, b, A) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:A]

//判断字符串是否为空
//#define DS_NULL(str) str==nil?@"":str

//判断设备系统版本
#define IOS7_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.1)

//显示alertView
#define alertShow(info)\
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:info delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil];\
[alert show];

//默认图片
#define defaultImage [UIImage imageNamed:@"default"]
//本地图片
#define image(name) [UIImage imageNamed:name];
//String转NSURL格式
#define DS_URL(ds_str) [NSURL URLWithString:ds_str];


//DEBUG和release下的NSLog
#ifdef DEBUG
#define DSLog(...) NSLog(__VA_ARGS__);
#define DSLOG_METHOD NSLog(@"%s", __func__);
#else
#define DSLog(...);
#define LOG_METHOD;
#endif


//关于时间
#define DSTimeIntervalMilliseconds(x) (NSTimeInterval)(x / 1000.)
#define DSTimeIntervalSeconds(x) (NSTimeInterval)x
#define DSTimeIntervalMinutes(x) (NSTimeInterval)(x * 60.)
#define DSTimeIntervalHours(x) (NSTimeInterval)(x * 3600.)
#define DSTimeIntervalDays(x) (NSTimeInterval)(x * 3600. * 24.)

//关于国际化
//#define DSLocalizedString(s) NSLocalizedString(s,s)
#define DSLocalizedString(s,d) NSLocalizedString(s,d)
#define _(s) NSLocalizedString(s,s)

//关于block的self
#define WeakSelf __weak typeof(self) weakSelf = self;  // WeakSelf;
#define WeakObj(o) __weak typeof(o) o##Weak = o;        //使用:weakObj(obj)
#define _weakObj(o) autoreleasepool{} __weak typeof(o) o##Weak = o;  //使用:@WeakObj(obj);









#endif /* DSMacros_h */
